﻿var status = 0;
var choice;
var scrolls = Array(
Array("", 1000000, 0),
Array("", 1000001, 0),
Array("", 1000002, 0),
Array("", 1000003, 0),
Array("", 1000004, 0),
Array("", 1000005, 0),
Array("", 1000006, 0),
Array("", 1000007, 0),
Array("", 1000008, 0),
Array("", 1000009, 0),
Array("", 1000010, 0),
Array("", 1000011, 0),
Array("", 1000012, 0),
Array("", 1000013, 0),
Array("", 1000014, 0),
Array("", 1000015, 0),
Array("", 1000016, 0),
Array("", 1000017, 0),
Array("", 1000018, 0),
Array("", 1000019, 0),
Array("", 1000020, 0),
Array("", 1000021, 0),
Array("", 1000022, 0),
Array("", 1000023, 0),
Array("", 1000024, 0),
Array("", 1000026, 0),
Array("", 1000027, 0),
Array("", 1000028, 0),
Array("", 1000029, 0),
Array("", 1000030, 0),
Array("", 1000031, 0),
Array("", 1000032, 0),
Array("", 1000033, 0),
Array("", 1000035, 0),
Array("", 1000036, 0),
Array("", 1000037, 0),
Array("", 1000038, 0),
Array("", 1000041, 0),
Array("", 1000042, 0),
Array("", 1000043, 0),
Array("", 1000044, 0),
Array("", 1000045, 0),
Array("", 1000046, 0),
Array("", 1000050, 0),
Array("", 1000051, 0),
Array("", 1000052, 0),
Array("", 1000053, 0),
Array("", 1001000, 0),
Array("", 1001001, 0),
Array("", 1001002, 0),
Array("", 1001003, 0),
Array("", 1001004, 0),
Array("", 1001005, 0),
Array("", 1001006, 0),
Array("", 1001007, 0),
Array("", 1001008, 0),
Array("", 1001009, 0),
Array("", 1001010, 0),
Array("", 1001011, 0),
Array("", 1001012, 0),
Array("", 1001013, 0),
Array("", 1001014, 0),
Array("", 1001015, 0),
Array("", 1001016, 0),
Array("", 1001017, 0),
Array("", 1001018, 0),
Array("", 1001019, 0),
Array("", 1001020, 0),
Array("", 1001021, 0),
Array("", 1001022, 0),
Array("", 1001023, 0),
Array("", 1001024, 0),
Array("", 1001025, 0),
Array("", 1001026, 0),
Array("", 1001027, 0),
Array("", 1001028, 0),
Array("", 1001029, 0),
Array("", 1001030, 0),
Array("", 1001031, 0),
Array("", 1001032, 0),
Array("", 1001033, 0),
Array("", 1001034, 0),
Array("", 1001036, 0),
Array("", 1001037, 0),
Array("", 1001038, 0),
Array("", 1001039, 0),
Array("", 1001040, 0),
Array("", 1001041, 0),
Array("", 1001042, 0),
Array("", 1001043, 0),
Array("", 1001044, 0),
Array("", 1001045, 0),
Array("", 1001046, 0),
Array("", 1001047, 0),
Array("", 1001048, 0),
Array("", 1001049, 0),
Array("", 1001055, 0),
Array("", 1001056, 0),
Array("", 1001057, 0),
Array("", 1001058, 0),
Array("", 1001061, 0),
Array("", 1001062, 0),
Array("", 1001063, 0),
Array("", 1001064, 0),
Array("", 1001065, 0),
Array("", 1001066, 0),
Array("", 1001068, 0),
Array("", 1001069, 0),
Array("", 1001070, 0),
Array("", 1001071, 0),
Array("", 1001075, 0),
Array("", 1001076, 0),
Array("", 1001077, 0),
Array("", 1001078, 0),
Array("", 1001082, 0),
Array("", 1001083, 0),
Array("", 1001084, 0),
Array("", 1002000, 0),
Array("", 1002015, 0),
Array("", 1002018, 0),
Array("", 1002031, 0),
Array("", 1002032, 0),
Array("", 1002070, 0),
Array("", 1002071, 0),
Array("", 1002076, 0),
Array("", 1002077, 0),
Array("", 1002078, 0),
Array("", 1002186, 0),
Array("", 1002187, 0),
Array("", 1002188, 0),
Array("", 1002189, 0),
Array("", 1002190, 0),
Array("", 1002191, 0),
Array("", 1002192, 0),
Array("", 1002193, 0),
Array("", 1002194, 0),
Array("", 1002195, 0),
Array("", 1002196, 0),
Array("", 1002197, 0),
Array("", 1002198, 0),
Array("", 1002199, 0),
Array("", 1002200, 0),
Array("", 1002201, 0),
Array("", 1002202, 0),
Array("", 1002203, 0),
Array("", 1002204, 0),
Array("", 1002205, 0),
Array("", 1002206, 0),
Array("", 1002219, 0),
Array("", 1002220, 0),
Array("", 1002221, 0),
Array("", 1002222, 0),
Array("", 1002223, 0),
Array("", 1002224, 0),
Array("", 1002225, 0),
Array("", 1002226, 0),
Array("", 1002227, 0),
Array("", 1002228, 0),
Array("", 1002229, 0),
Array("", 1002230, 0),
Array("", 1002231, 0),
Array("", 1002232, 0),
Array("", 1002233, 0),
Array("", 1002234, 0),
Array("", 1002235, 0),
Array("", 1002236, 0),
Array("", 1002237, 0),
Array("", 1002238, 0),
Array("", 1002239, 0),
Array("", 1002240, 0),
Array("", 1002241, 0),
Array("", 1002250, 0),
Array("", 1002251, 0),
Array("", 1002255, 0),
Array("", 1002256, 0),
Array("", 1002257, 0),
Array("", 1002258, 0),
Array("", 1002259, 0),
Array("", 1002260, 0),
Array("", 1002261, 0),
Array("", 1002262, 0),
Array("", 1002263, 0),
Array("", 1002264, 0),
Array("", 1002265, 0),
Array("", 1002266, 0),
Array("", 1002279, 0),
Array("", 1002280, 0),
Array("", 1002290, 0),
Array("", 1002291, 0),
Array("", 1002292, 0),
Array("", 1002293, 0),
Array("", 1002294, 0),
Array("", 1002295, 0),
Array("", 1002296, 0),
Array("", 1002297, 0),
Array("", 1002298, 0),
Array("", 1002299, 0),
Array("", 1002300, 0),
Array("", 1002301, 0),
Array("", 1002302, 0),
Array("", 1002303, 0),
Array("", 1002304, 0),
Array("", 1002305, 0),
Array("", 1002306, 0),
Array("", 1002307, 0),
Array("", 1002308, 0),
Array("", 1002309, 0),
Array("", 1002310, 0),
Array("", 1002311, 0),
Array("", 1002312, 0),
Array("", 1002313, 0),
Array("", 1002314, 0),
Array("", 1002315, 0),
Array("", 1002316, 0),
Array("", 1002317, 0),
Array("", 1002318, 0)
);

function start() {
    status = -1;
    action(1, 0, 0);
}

function action(mode, type, selection) {
    if (mode == -1) cm.dispose();
    else {
        if (status == 0 && mode == 0) {
            cm.dispose();
            return;
        } else if (status >= 1 && mode == 0) {
            cm.sendOk("好吧，欢迎下次继续光临！.");
            cm.dispose();
            return;
        }
        if (mode == 1) status++;
        else status--;

        if (status == 0) {
            choices = "\r\n兔兔币余额：#r" + cm.getHyPay(1) + "#k个 (#r买后不支持退货哟亲#k)";
            for (var i = 0; i < scrolls.length; i++) {
                choices += "\r\n#L" + i + "##v" + scrolls[i][1] + "##z" + scrolls[i][1] + "#　#d需要#r" + scrolls[i][2] + "#d兔兔币#k#l";
            }
            cm.sendSimpleS("欢迎来到时尚帽子店,你想买我们商店的物品么?请选择吧：." + choices,2);
        } else if (status == 1) {
            cm.sendYesNo("你确定需要购买#v" + scrolls[selection][1] + "##t" + scrolls[selection][1] + "#?");
		choice = selection;
        } else if (status == 2) {
            var money = scrolls[choice][2];
            if (cm.getHyPay(1) < money) {
                cm.sendOk("抱歉，你没足够的兔兔币！");
                cm.dispose();
            } else {
                cm.addHyPay(money);
                cm.gainItem(scrolls[choice][1], 1);
                cm.sendOk("购买成功.");
                cm.dispose();
            }
        }
    }
}